#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
****************************************************
Project:python
Filename: apihz.py
Author:银河sa_js asdf1234
Create: 2025/10/14 上午10:59 
Notes:接口盒子  https://www.apihz.cn/
cron: 26 2 * * *
***************************************************
'''

import requests

class FreeApi:
    def __init__(self):
        self.key = "9c2a7d39497d7fc5956a562180f088ad"
        self.id = 10008836
        self.headers = {
            "accept": "application/json, text/javascript, */*; q=0.01",
            "accept-language": "zh-CN,zh;q=0.9",
            "cache-control": "no-cache",
            "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
            "origin": "https://www.apihz.cn",
            "pragma": "no-cache",
            "priority": "u=1, i",
            "referer": "https://www.apihz.cn/user/qiandao2.php",
            "sec-ch-ua": "'Google Chrome';v='141', 'Not?A_Brand';v='8', 'Chromium';v='141'",
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": "'Windows'",
            "sec-fetch-dest": "empty",
            "sec-fetch-mode": "cors",
            "sec-fetch-site": "same-origin",
            "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36",
            "x-requested-with": "XMLHttpRequest"
        }

    def qiandao(self):
        url = "https://www.apihz.cn/user/ajax.php?act=qiandao"
        data = {
            "getuserid": self.id,
            "getuserkey": self.key
        }

        res = requests.post(url=url, data=data, headers=self.headers).json()
        print(res)

        self.weixin(res['msg'])

    def weixin(self, content):
        data = {
            "title": "接口盒子签到提醒",
            "content": content
        }
        res = requests.post(url="http://yh.xuenn.cn/api/weixin/", data=data)
        if res.status_code == 200:
            print('pushplus推送成功')
            return 'pushplus推送成功'
        else:
            print('系统错误，pushplus推送失败')
            return '系统错误，pushplus推送失败'

    def main(self):
        self.qiandao()


if __name__ == '__main__':
    FreeApi().main()